﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SoundServant.Controls
{
    /// <summary>
    /// Interaction logic for NavTab.xaml
    /// </summary>
    public partial class DetailNavTab : UserControl
    {
        public event MouseButtonEventHandler Clicked;
        private bool isSelected = false;

        public DetailNavTab()
        {
            InitializeComponent();
        }

        public UIElement TabPage;

        Brush selectedBgBrush = Brushes.White;
        Brush unSelectedBgBrush = Brushes.Black;
        Brush selectedFgBrush = Brushes.Black;
        Brush unSelectedFgBrush = Brushes.White;

        public Brush BgBrush { get { return unSelectedBgBrush; } set { unSelectedBgBrush = value; if (!isSelected) Tab.Background = value; } }
        public String NavTitle { get { return TabLabel.Content.ToString(); } set { TabLabel.Content = value; } }
        public String Detail { get { return DetailLabel.Content.ToString(); } set { DetailLabel.Content = value; } }

        public void Select()
        {
            isSelected = true;
            SelectedOverlay.Visibility = Visibility.Visible;
            TabLabel.FontWeight = FontWeights.Bold;
            TabLabel.Foreground = Brushes.Black;
            this.Margin = new Thickness(0, 0, 6, 0);
        }

        public void Unselect()
        {
            isSelected = false;
            SelectedOverlay.Visibility = Visibility.Collapsed;
            TabLabel.FontWeight = FontWeights.Normal;
            TabLabel.Foreground = Brushes.White;
            TabLabel.Margin = new Thickness(0, 0, 0, 0);
        }

        public void Click(MouseButtonEventArgs _e)
        {
            if (!isSelected)
            {
                Select();
                if (Clicked != null) Clicked(this, _e);
            }
        }

        private void Tab_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!isSelected)
            {
                Select();
                if (Clicked != null) Clicked(this, e);
            }
        }
    }
}
